package com.work.device.service.Impl;


import com.work.device.dao.MyDeviceMapper;
import com.work.device.pojo.Device;
import com.work.device.pojo.MyDevice;
import com.work.device.service.MyDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MyDeviceServiceImpl implements MyDeviceService {
    @Autowired
    private MyDeviceMapper myDeviceMapper;

    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public List<MyDevice> findAll() {
        return myDeviceMapper.selectAll();
    }

    /**
     * 自行采购
     *
     * @param map
     */
    @Override
    public void add(Map<String, Object> map) {
        String code = (String) map.get("code");
        Integer did = Integer.parseInt((String) map.get("did"));
        String cid = "123467";
        MyDevice myDevice = new MyDevice();
        myDevice.setInstall("0");
        myDevice.setStatus("0");
        myDevice.setDid(did);
        myDevice.setCode(code);
        myDevice.setCid(Integer.parseInt(cid));
        myDeviceMapper.insertSelective(myDevice);
    }



    /**
     * 修改设备
     *
     * @param mydevice
     * @return
     */
    @Override
    public Integer updateById(MyDevice mydevice) {
        return myDeviceMapper.updateByPrimaryKeySelective(mydevice);
    }


    /**
     * 根据设备id删除设备
     *
     * @param id
     * @return
     */
    @Override
    public Integer delete(Long id) {
        //删除设备
        return myDeviceMapper.deleteByPrimaryKey(id);
    }


}

